package com.jing.cloud.service.chat.adapter;

import com.jing.cloud.service.chat.adapter.handler.MessageHandler;
import lombok.Setter;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by 29017 on 2017/9/10.
 */
@Component
public class MessageAdapter {

    @Setter
    private static List<MessageHandler> messageHandlers;

    public static boolean handleMessage(MessageBean messageBean) {
        for (MessageHandler messageHandler : messageHandlers) {
            boolean result = messageHandler.handleMessage(messageBean);
            if (!result) {
                return false;
            }
        }
        return true;
    }

}
